package com.qdu.bean;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class temp_atempBean implements WritableComparable<temp_atempBean> {

    private double  temp;
    private double  atemp;
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy MM");

    public temp_atempBean() {
    }


    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeDouble(temp);
        dataOutput.writeDouble(atemp);

    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        temp=dataInput.readDouble();
        atemp=dataInput.readDouble();
    }

    @Override
    public String toString() {
        return   temp +" "+atemp ;
    }

    public temp_atempBean(double temp, double atemp) {
        this.temp = temp;
        this.atemp = atemp;
    }

    public double getTemp() {
        return temp;
    }

    public void setTemp(double temp) {
        this.temp = temp;
    }

    public double getAtemp() {
        return atemp;
    }

    public void setAtemp(double atemp) {
        this.atemp = atemp;
    }

    public void set(double  temp,double atemp){
        this.temp=temp;
        this.atemp=atemp;

    }

    @Override
    public int compareTo(temp_atempBean o) {
        try {
            long thisValue = sdf.parse(this.toString()).getTime();
            long thatValue=sdf.parse(o.toString()).getTime();
            return (thisValue<thatValue?-1:(thisValue == thatValue ? 0 : 1));//若this<that为1，是倒序，若this<that 为-1,是正序
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return -2;
    }
}
